//
//  PopupView.m
//  LewPopupViewController
//
//  Created by deng on 15/3/5.
//  Copyright (c) 2015年 pljhonglu. All rights reserved.
//

#import "PopupView.h"
#import "UIViewController+LewPopupViewController.h"
#import "LewPopupViewAnimationFade.h"
#import "LewPopupViewAnimationSlide.h"
#import "LewPopupViewAnimationSpring.h"
#import "LewPopupViewAnimationDrop.h"

@implementation PopupView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        // Initialization code
               
    }
    return self;
}

- (instancetype)initWithInformaiton:(NSString*)information withFrame:(CGRect)frame isShowButton:(BOOL)isShow{
    
    
    
    self=[super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor=[UIColor whiteColor];
        
        UITextView*label=[[UITextView alloc] initWithFrame:CGRectMake(10, 15, self.width-20, self.height-30)];
        
        label.font=[UIFont systemFontOfSize:14];
        
//        if (self.height==SCREEN_HEIGHT/2.0) {
//            
//            label.selectable=YES;
//            
//            label.editable=YES;
//            
//        }else{
//            
//            label.selectable=NO;
//            
//            label.editable=NO;
//        }
        
        label.selectable=NO;
        
        label.editable=NO;
        
        label.text=information;
        
        [self addSubview:label];
        
        self.layer.cornerRadius=15;
        self.clipsToBounds=YES;
        
        
        
        
        if (isShow==YES) {
            
            UIButton*button=[UIButton buttonWithType:UIButtonTypeCustom];
            
            button.frame=CGRectMake(-8, -8, 33, 33);
            
            [button setImage:[UIImage imageNamed:@"btn1_nor"] forState:0];
            
            [button addTarget:self action:@selector(dismissPopView) forControlEvents:UIControlEventTouchUpInside];
            
            [self addSubview:button];

        }else{

        
            
        }
        
    }
    
    
    return self;
 
    
}

-(void)dismissPopView{
    if (self.dismissView) {
        
        self.dismissView();
        
    }
    
    
    
}

@end
